<!-- Portfolio Grid Section -->
<section id="portfolio" class="bg-light-gray" style="margin-top:-110px;">
    <div class="container">

            <div class="row">
                <div class="col-lg-12 text-center">
                    <h2 class="section-heading"><?= $Heading ?></h2>
                </div>
                    <div class="col-lg-12 text-center">
                    <center>
                        <div class="input-group" >
                                <input id="search_q" name="search" class="form-control" placeholder="Search" style="width:70%">
                                <select id="sel" class="form-control" style="margin-top:-34px; margin-left:70%;width:30%;" >
                                    <option>Ads</option>
                                    <option>Notes</option>
                                    <option>Users</option>
                                </select>    
                                <button id="search_btn"  onclick="search_rout('<?=base_url()?>')" style="margin-left:99%; margin-top:-57px;" class="btn btn-primary"><i class="fa fa-search"></i></button>
                                <br><br>
                        </div>

                        <br>
                        <div class="row">
                            <div class="panel panel-default">
                                <div class="panel-body">
                                    <div class="col-md-2">
                                        <h4>Sort by: </h4>
                                    </div>
                                    <div class="col-md-4">                                    
                                            <select class="form-control" id="sort_by">
                                                <option value="price">Price</option>
                                                <option value="timestamp">Date</option>  
                                                <option value="views">Views</option> 
                                                <option value="ad_title">Alphabetical</option> 
                                            </select>
                                    </div>

                                     <div class="col-md-2">
                                        <select class="form-control" id="sort_order">
                                            <option value="asc">&uarr; &nbsp;Ascending</option>
                                            <option value="desc">&darr; &nbsp;Descending</option>    
                                        </select>   
                                    </div>

                                    <div class="col-md-2">
                                        <button onclick="sort_ads('<?php echo base_url(); ?>', <?= $cat ?>)" class="btn btn-primary">SORT</button>
                                    </div>
                                </div>
                             </div>   
                        </div>                      
                    </center>
                    <br>
                </div>
            </div>



     <?php $endl = 1;
            $id = 0;
      ?>       
        
            <?php foreach($records as $row) {
                   if($row->active == 1) 
                   {

                       if($endl%4==0)
                       echo "<div class='row'>"; 
                        ?>
                        <div class="col-md-3 col-sm-4 portfolio-item">
                            <a href="#portfolioModal<?php echo $id; ?>" class="portfolio-link" data-toggle="modal">
                                <div class="portfolio-hover">
                                    <div class="portfolio-hover-content">
                                        <i class="fa fa-plus fa-3x"></i>
                                    </div>
                                </div>
                                <div style="height:170px; overflow:hidden; border: 1px solid; border-color:#e0e0e0; background:#e0e0e0;">
                                    <center>
                                        <img src='<?php echo $row->img_1; ?>'  class="img-responsive" alt="">
                                    </center>
                                </div>
                            </a>
                            <div class="portfolio-caption">
                                <h4><?php echo $row->ad_title; ?></h4>
                                <p class="text-muted"><?php echo $row->price; ?> pkr</p>
                            </div>
                        </div>



                        <?php
                        if($endl % 4 ==0)
                            echo "</div>";

                        $endl++;
                        $id++; 

                         }
                    }
              ?> 
  
        <div class="row">
            <div class="col-md-12">
                <center>
                    <?php echo $this->pagination->create_links(); ?>
                </center>
            </div>
        </div>

    </div>
</section>


<!-- modals -->
<?php 
$i=0;
foreach($records as $row) { 
    if($row->active ==1){
    ?>

    <div class="portfolio-modal modal fade" id="portfolioModal<?php echo $i; ?>" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-content">
            <div class="close-modal" data-dismiss="modal">
                <div class="lr">
                    <div class="rl">
                    </div>
                </div>
            </div>
            <div class="container">
                <div class="row">
                    <div class="col-lg-8 col-lg-offset-2">
                        <div class="modal-body">
                            <!-- Project Details Go Here -->
                            <h2><?php echo $row->ad_title; ?></h2>
                                <p class="item-intro text-muted"><b>Posted By</b></p>
                            
                                <center>
                                    <div class="img-div-xsml"  >
                                        <img src='<?php echo $row->dp; ?>' />
                                    </div> 
                                </center>
                                
                                <center>
                                    <p class="item-intro"><a  href="<?= base_url() ?>Site/view_profile/<?= $row->user_id ?>"><?php echo $row->full_name; ?></a></p>
                                </center>
                                                            
                            <br>

                            <div class="row">
                                <div class="col-md-12">
                                    <center>
                                     <img class="img-responsive" data-toggle="magnify" src='<?php echo $row->img_1; ?>' alt="">
                                     </center>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6">
                                    <center>
                                    <img class="img-responsive"   src='<?php echo $row->img_2; ?>' alt="">
                                    </center>
                                </div>
                                <div class="col-md-6">
                                    <center>
                                    <img class="img-responsive" src='<?php echo $row->img_3; ?>' alt="">
                                    </center>
                                </div>
                            </div>
      
                            
                            <h3>Discription:</h3>
                            <p><?= $row->disc; ?></p>
                            
                            <p><strong>Contact #:</strong><?= $row->contact; ?></p>
                            <button class="btn btn-primary">Send E-mail</button>
                            <br><br>
                            
                            <ul class="list-inline">
                                <li><p><b>Date:</b> <?= $row->timestamp; ?></p></li>
                                <li><p><b>Price: </b><?= $row->price; ?>Rs</p></li>
                                <li><p><b>Category: </b><?= $row->cat_name ?></p></li>
                            </ul>
                            <ul class="list-inline">
                                <li><p><b>Keywords:</b><?= $row->keywords ?></p></li>
                                
                            </ul>
                            
                            <button type="button" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-times"></i>Close</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

        <?php 
        $i++;
    }
} ?>